package io.renren.admin;

import io.renren.model.ClientMessage;
import io.renren.model.ServerMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.messaging.handler.annotation.MessageMapping;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.messaging.simp.annotation.SubscribeMapping;
import org.springframework.stereotype.Controller;

/**
 * @Author: zyx
 * @Date: 2018/11/16 15:16
 * @Version 1.0
 */
@Controller
public class WebSocketController {
  private Logger logger = LoggerFactory.getLogger(this.getClass());

  @MessageMapping("/sendTest")
  @SendTo("/topic/subscribeTest")
  public ServerMessage sendDemo(ClientMessage message) {
    logger.info("接收到了信息" + message.getName());
    return new ServerMessage("你发送的消息为:" + message.getName());
  }

  @SubscribeMapping("/subscribeTest")
  public ServerMessage sub() {
    logger.info("XXX用户订阅了我。。。");
    return new ServerMessage("感谢你订阅了我。。。");
  }


}
